<?php

declare(strict_types=1);

namespace App\CustHub\Controller;

use App\CustHub\Annotation\ApiAuth;
use App\CustHub\Annotation\ChOperationLog;
use App\CustHub\Annotation\ChPermission;
use App\CustHub\Annotation\VerifySignature;
use App\CustHub\Request\ChCorpBlackRequest;
use App\CustHub\Service\ChCorpBlackService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;

/**
 * 企业黑名单
 */
#[Controller(prefix: 'ch/corp/black'),ApiAuth,VerifySignature]
class ChCorpBlackController extends BaseController
{
    #[Inject]
    protected ChCorpBlackService $service;

    #[PostMapping('list'),ChPermission('ch:corp:black:list')]
    public function list()
    {
        return $this->success($this->service->list($this->request->all()));
    }

    #[PostMapping('save'),ChOperationLog]
    public function save(ChCorpBlackRequest $request)
    {
        return $this->success(['id'=>$this->service->save($request->all())]);
    }

    #[PostMapping('delete'),ChOperationLog]
    public function delete(ChCorpBlackRequest $request)
    {
        return $this->service->deleteBlack($request->all()) ? $this->success('删除成功') : $this->error('删除失败');
    }
}